<!DOCTYPE html>
<html lang="en" class="no-js" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout" layout:decorator="layout">
<head>
<title>多倍积分管理</title>
</head>
<body>
<div layout:fragment="content">
	<div class="row">
		<div class="col-md-12">
			<div class="btn-group pull-right">
				<a href="index.html" th:href="@{/promotion/credit/list/}" id="sample_editable_1_new" class="btn green">返回<i class="fa fa-arrow-circle-o-left"></i></a>
			</div>
		</div>
	</div>
	<div class="row">
		<div class="col-md-12">
			<h4 class="form-section">多倍积分信息</h4>
				<form role="form" id="form" th:action="@{/promotion/credit/save}" th:object="${creditPromotion}" method="post" class="form-horizontal">
					<input type="hidden" th:field="*{id}" />
					<div class="form-group" th:class="${#fields.hasErrors('creditName')}? 'form-group has-error' : 'form-group'">
							<label class="control-label col-md-3">名称<span class="required" aria-required="true">* </span></label>							
							<div class="col-md-4">
								<input type="text" class="form-control" placeholder="名称" th:field="*{creditName}"/>
								<span class="help-block" th:if="${#fields.hasErrors('creditName')}" th:errors="*{creditName}">活动名称不能为空</span>
							</div>
						</div>
						<div class="form-group" th:class="${#fields.hasErrors('startTime')}? 'form-group has-error' : 'form-group'">
                            <label class="control-label col-md-3">开始时间<span class="required" aria-required="true">* </span></label>
                            <div class="col-md-4">
                                <input id="start_time" th:field="*{startTime}" class="form-control" type="text"></input>
                                <span class="help-block" th:if="${#fields.hasErrors('startTime')}" th:errors="*{startTime}">请输入开始时间</span>
                            </div>
						</div>
						
						<div class="form-group" th:class="${#fields.hasErrors('endTime')}? 'form-group has-error' : 'form-group'">
						    <label class="control-label col-md-3">结束时间<span class="required" aria-required="true">* </span></label>
							<div class="col-md-4">
								<input id="end_time" th:field="*{endTime}" data-format="yyyy-MM-dd hh:mm:ss" class="form-control" type="text"></input>
								<span class="help-block" th:if="${#fields.hasErrors('endTime')}" th:errors="*{endTime}">请输入结束时间</span>
							</div>
						</div>
                        <div class="form-group" th:class="${#fields.hasErrors('creditCategoryList')}? 'form-group has-error' : 'form-group'">
                            <label class="control-label col-md-3">积分类型<span class="required" aria-required="true">* </span></label>
                            <div class="col-md-4">
                                <div class="checkbox-list">
                                    <label class="checkbox-inline" th:each="creditCategory : ${creditCategoryValues}"><span><input type="checkbox" th:attr="id=${'checkbox_creditCategory_'+creditCategoryStat.index}" name="checkbox_creditCategory" th:field="*{creditCategoryList}" th:text="${creditCategory.description}" th:value="${creditCategory}"/></span></label>
                                    <span class="help-block" th:if="${#fields.hasErrors('creditCategoryList')}" th:errors="*{creditCategory}"></span>
                                </div>
                            </div>
                        </div>
                        <div class="form-group" th:class="${#fields.hasErrors('creditType')}? 'form-group has-error' : 'form-group'">
                            <label class="control-label col-md-3">赠送方式<span class="required" aria-required="true">* </span></label>
                            <div class="col-md-4">
                                <div class="radio-list">
                                    <label class="radio-inline" th:each="creditType : ${creditTypeValues}"><span><input type="radio" th:attr="id=${'radio_creditType_'+creditTypeStat.index}" name="radio_creditType" th:field="*{creditType}" th:text="${creditType.description}" th:value="${creditType}"/></span></label>
                                    <span class="help-block" th:if="${#fields.hasErrors('creditType')}" th:errors="*{creditType}"></span>
                                </div>
                            </div>
                        </div>
						<div class="form-group">
							<label class="control-label col-md-3">享受优惠会员等级<span class="required" aria-required="true">* </span></label>
							<div class="col-md-5">
					            <div class="checkbox-list">
                                    <label class="checkbox-inline"
                                        th:each="data : ${userRanks}">
                                            <span><input
                                                th:field="*{UserRank}"  th:checked="${data.id}" type="checkbox" name="userRankID"
                                                th:value="${data.id}" th:text="${data.rankName}" id="userRankID"/>
                                            </span>
                                    </label>
								</div>
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-md-3">促销简介</label>							
							<div class="col-md-4">
								<textarea id="textarea_content" rows="4" type="text" class="form-control" placeholder="促销简介" th:field="*{descirption}" />
							</div>
						</div>	
					<div class="form-actions fluid">
						<div class="col-md-offset-3 col-md-9">
							<button type="submit" id="btn_submit" class="btn blue">提交</button>
						</div>
					</div>
				</form>		
			</div>
		</div>
	</div>
</body>
</html>
<script th:inline="javascript">
	/*<![CDATA[*/
		$("#start_time").click(function(){
			WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true,readOnly:true});
		}).focus(function () {
            WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true,readOnly:true});
        });
		$("#end_time").click(function(){
			WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true,readOnly:true});
		}).focus(function () {
            WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true,readOnly:true});
        });
	          
		$('#btn_search').click(function() {
			var _sn = $('#goodsSn').val();
    		BOSS.remoteCall('creditGoods/ajaxSearch',$('#selt_goodsType'),{goodsSn:_sn});
		});

    $(document).ready(function(){
        $("#form").validate({
            rules:{
                creditName:{
                    required:true,
                    maxlength:100
                },
                startTime : {
                    required:true
                },
                endTime : {
                    required:true
                },
                creditCategoryList: {
                    required:true
                },
                UserRank: {
                    required: true
                }

            }
        });
    });

	/*]]>*/
</script>